//个人中心页面api文件

import shopAxios from '../utils/request.js'

const BASE_URL = '/user'
    //修改用户密码
export async function updatePass(user) {
    const resp = await shopAxios.post('/admin/changePassword', {
        "userName": user.username,
        "passWord": user.password
    })
    return resp
}

export function uploadAvatar(file) {
    const formData = new FormData();
    formData.append('file', file);
    // console.log(file);
    return shopAxios({
        method: 'post',
        url: `${BASE_URL}/uploadAvatar`,
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}
export function saveAvatarURL(url, username) {
    return shopAxios({
        method: 'post',
        url: `${BASE_URL}/saveAvatarURL`,
        data: {
            url,
            username
        }
    })
}

// 获取用户头像url
export async function getAvatarURL(username) {
    const resp = await shopAxios.get('/user/getAvatarURL', {
        params: { "userName": username }
    })
    // console.log(resp);
    
    return resp;
}